// pages/myself/myself.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    TabCur: 0,
    scrollLeft: 0,
    tablist: ["笔记", "收藏"],
    allnoteList: [{
        coverUrl: "/image/jett太可爱了🥺_1_chamber-_-_来自小红书网页版.jpg",
        title: "生气的Jeet",
        headUrl: "/image/jeet.jpg",
        userName: "赵",
        likeNum: "136",
        islike: "1",
        category: [1]
      },
      {
        coverUrl: "/image/Kyrie WallPaper 高清_1_籃球人🏀_来自小红书网页版.jpg",
        title: "Kyrie Lrving",
        headUrl: "/image/Kyrie.jpg",
        userName: "欧文中文网",
        likeNum: "2.6w",
        islike: "1",
        category: [0,1]
      },
      {
        coverUrl: "/image/这么帅气的彭于晏你不看看吗🧐_1_快乐娱悦_来自小红书网页版.jpg",
        title: "不是，谁把我照片发出来了",
        headUrl: "/image/彭于晏.jpg",
        userName: "娱乐小圈",
        likeNum: "7w",
        islike: 1,
        category: [1]
      },
      {
        coverUrl: "/image/这张真的好帅啊啊啊啊我伦😭_1_路小雨写立可白i_来自小红书网页版.jpg",
        title: "白毛伦YYDS",
        headUrl: "/image/路小雨.jpg",
        userName: "小雨写可对白",
        likeNum: "51w",
        islike: "1",
        category: [0,1]
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let list = this.data.allnoteList;
    let newList = [];
    for (let index = 0; index < list.length; index++) {
        if (!(list[index].category.indexOf(0) == -1)){
            newList.push(list[index])
        }
    }
    this.setData({
        noteList: newList
    })
  },
  tabSelect(e) {
    let list = this.data.allnoteList;
      let categoryId = e.currentTarget.dataset.id;
      let newList = [];
      for (let index = 0; index < list.length; index++) {
        if (!(list[index].category.indexOf(categoryId) == -1)){
            newList.push(list[index])
        }
    }
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id - 1) * 60,
            noteList:newList
        })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})